package chapter07ynny.作业一_KTV模拟点歌;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import java.util.TreeSet;

public class MusicTest {
    public static void main(String[] args) {
        Music music =new Music();
        boolean bo1;
//        ArrayList<String> arrayList =new ArrayList<>();
//       HashSet<String> hashSet = new HashSet<>();
//        TreeSet<String>treeSet =new TreeSet<>();
//        treeSet.add("aaaa");treeSet.add("bbbb");treeSet.add("cccc");
//        hashSet.add("a");hashSet.add("b");hashSet.add("c");
//        arrayList.addAll(hashSet);
//        arrayList.addAll(treeSet);
//        System.out.println(arrayList);
//        arrayList.removeAll(treeSet);
//        System.out.println(arrayList);

        ArrayList<String>arrayList=new ArrayList<>();

        while (true){



            System.out.println("-----------------------------");
            System.out.println("-------------1点歌-------------");
            System.out.println("--------------2置顶--------------");
            System.out.println("--------------3前移----------------");
            System.out.println("---------------4列表-----------------");
            System.out.println("--------------5退出--------------");

            Scanner sca = new Scanner(System.in);
            int choose = sca.nextInt();

            switch (choose){
                case 1:
                    System.out.println("输入歌名");
                    String name = sca.next();
                    bo1=arrayList.contains(name);
                    if (bo1==false){
                        music.setMusicName(name);
                        arrayList.add(music.getMusicName());
                    }else {
                        System.out.println("这首歌已经在歌单中！");
                    }



                    break;
                case 2:

                    System.out.println("输入歌名");
                    String topname = sca.next();
                    music.setMusicName(topname);
                    arrayList.remove(topname);

                    arrayList.add(0,topname);
                    break;
                case 3:
                    System.out.println("输入歌名");
                    String found = sca.next();
                    if (arrayList.contains(found)){
                        if (arrayList.indexOf(found)!=0){
                            int i = arrayList.indexOf(found);
                            String str = arrayList.get(i-1);
                            arrayList.set(i,str);
                            arrayList.set(i-1,found);
                        }
                        else if (arrayList.indexOf(found)==0){
                            System.out.println("这首歌已经是第一首了!!");
                        }
                    }
                    else {
                        System.out.println("抱歉！这首歌不在歌单内");
                    }
                    break;
                case 4:
                    int j =0;
                    for (String i:arrayList){
                        j++;
                        System.out.println(j+"········"+"《"+i+"》");
                    }
                    break;
                case 5:
                    return;
            }
        }
    }
}

